//
//  ThemeCell.m
//  ZhiHuDaily
//
//  Created by albert on 16/8/27.
//  Copyright © 2016年 albert. All rights reserved.
//

#import "ThemeCell.h"
#import "NewsListModel.h"
#import "UIImageView+WebCache.h"

@interface ThemeCell ()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIImageView *rightImageView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelRightCons;
@end

@implementation ThemeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(NewsListModel *)model{
    _model = model;
    
    self.titleLabel.text = model.title;
    
    self.labelRightCons.constant = (!self.model.images) ? -70 : 18;
    
    if (!self.model.images) {
        self.rightImageView.image = nil;
       return;
    }
    
    [self.rightImageView sd_setImageWithURL:[NSURL URLWithString:self.model.images[0]] placeholderImage:[UIImage imageNamed:@"Image_Preview"]];
}

#pragma mark - 更新皮肤
- (void)changeToNightSkin{// 夜间
    self.backgroundColor = JKNightSkinColor;
    self.titleLabel.textColor = self.model.alreadyRead ? JKColor(128, 128, 128) : JKColor(186, 186, 186);
}

- (void)changeToDaySkin{// 白天
    self.backgroundColor = JKGlobalBgColor;
    self.titleLabel.textColor = self.model.alreadyRead ? JKColor(96, 96, 96) : [UIColor blackColor];
}
@end
